<?php session_start(); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Parent Informer RCSHS - Internet Connection Detection</title>

<link rel=stylesheet href="../../css-layouts/themes/defaulttheme.css" type="text/css">
<link rel=stylesheet href="../../css-layouts/headlinks.css" type="text/css">

</head>

<body><div id="mainhead"><br><br><br></div>

<hr><br>

<?php

 require_once("../../sqlconfig.php");

 mysql_connect($server, $sqlusr, $sqlpass) or die(mysql_error()); 
 mysql_select_db($mydb) or die(mysql_error()); 

 //Checks if there is a login cookie
 if(isset($_COOKIE["parentinformerprcshs"]) || isset($_COOKIE["parentinformerurcshs"])) { 
  if(isset($_COOKIE["parentinformerprcshs"])) {
   $username = $_COOKIE["parentinformerprcshs"]; 
  }
  else {
   $_SESSION['theerrcode'] = 2;
   header("Location: ../logerr_atmpt.php");
  }
  $pass = $_COOKIE["parentinformerurcshs"];
  $check = mysql_query("SELECT * FROM logtbl WHERE usernm = '".$username."'") or die(mysql_error());
  while($info=mysql_fetch_array($check)) {
   if ($pass!=$info['pwrnd']) {
    $_SESSION['theerrcode'] = 2;
    header("Location: ../logerr_atmpt.php");
   }
   else {

    $testsite=@fsockopen("www.gmail.com", 80);
    if(!$testsite) {
?>

<center><font id="heading">NO INTERNET CONNECTION</font></center>
<br><br>

<p align="left">
To enable the mail feature of this application, your computer must be<br>
connected to the internet. You will be redirected to the main page in 5<br>
seconds, or click <a href="../../">here</a>.<br><br>
<img src="../../img/prgbar.gif" alt="Bar Loader">
</p>

<?php

    }
    else {

?>

<center><font id="heading">INTERNET CONNECTION</font></center>
<br><br>

<p align="left">
You are already connected to the internet. As a result, the mail feature<br>
of this application is enabled. You will be redirected to the main page<br>
in 5 seconds or click <a href="../../">here</a>.<br><br>
<img src="../../img/prgbar.gif" alt="Bar Loader"> 
</p>

<?php

 
    }

   }
  }
 }
 else {
  header("Location: ../../");
 }

?>

<br>

<div class="footnav" align=center>

<hr>

<a href="../../">Main Page</a> ||
<a href="#">Help</a> ||
<a href="../../externalaffairs/links.php">Links</a> ||
<a href="#">About</a>
<br>

<span id="copyme">
&copy; 2011 Roosevelt College Science High School. All rights reserved.
</span>

</div>

<script type="text/javascript">
<!--

/*
 Count down then redirect script 2
 By William Kemper (kemperwilliam@hotmail.com)
 For this script and more, visit http://javascriptkit.com
*/

//specify redirect url
var redirecturl="../../";

//specify pause duration before redirection (in seconds)
var pausefor=5;

//DONE EDITING

function postaction() {
 if (window.timer) {
  clearInterval(timer);
  clearInterval(timer_2);
 }
 window.location=redirecturl;
}

setTimeout("postaction()",pausefor*1000);

//-->
</script>

</body>
</html>